{	Problem: http://codeforces.ru/problemset/problem/16/B
	Verdict: Accepted

}
var i,n,m:longint; a:Array[1..21,1..2] of longint; res:int64;
procedure qsort(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2][2];
repeat
  while a[i][2]>x do inc(i);
  while a[j][2]<x do dec(j);
  if i<=j then begin
    y:=a[i][2];
    a[i][2]:=a[j][2];
    a[j][2]:=y;
    y:=a[i][1];
    a[i][1]:=a[j][1];
    a[j][1]:=y;
    inc(i);
    dec(j);
  end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
readln(n,m);
for i:=1 to m do read(a[i][1],a[i][2]);
qsort(1,m);
res:=0;
i:=0;
while n>0 do begin
  inc(i);
  if a[i][1]<=n then begin
    dec(n,a[i][1]);
    inc(res,a[i][1]*a[i][2]);
  end else begin
    inc(res,a[i][2]*n);
    n:=0;
  end;
end;
writeln(res);
end.